#!/usr/bin/env python3
# _*_coding:utf-8 _*_
__author__ = "Gao"
from django import forms
from django.forms import fields
from django.forms import widgets
from repoistory import models


class ActionForm(forms.Form):
    '''Action'''
    def __init__(self, project_id, *args, **kwargs):
        super(ActionForm, self).__init__(*args, **kwargs)
        choices = [('','master')]
        choices.extend(models.Branch.objects.filter(project_id=project_id).values_list('branch', 'branch'))
        self.fields['branch'].choices=choices

    branch = fields.ChoiceField(label='Branch:',
                                widget=widgets.Select(attrs={'class': 'selectpicker','title':'---------'}), choices=[])

    action_choices = [('backup','备份'),('build','打包'),('update','更新'),
                      ('build_update','打包并更新'),('restart_service','重启服务')]
    action = fields.ChoiceField(label='操作:',
                                widget=widgets.Select(attrs={'class': 'selectpicker', 'title': '---------'}),
                                choices=action_choices,
                                required=False)
